// 导入封装的根路径
import request from '@/utils/request.js'

// 权限列表
export const getRightsApi = () => {
  return request({
    method: 'get',
    url: 'rights/list'
  })
}

// 角色列表
export const getRolesApi = () => {
  return request({
    method: 'get',
    url: 'roles'
  })
}

// 根据ID删除指定权限
export const getRemoveRightsApi = (data) => {
  return request({
    method: 'delete',
    url: `roles/${data.roleId}/rights/${data.rightId}`
  })
}

// 所有权限列表
export const getRightListApi = () => {
  return request({
    method: 'get',
    url: 'rights/tree'
  })
}

// 角色授权
export const getAuthorizationApi = (id, data) => {
  return request({
    method: 'post',
    url: `roles/${id}/rights`,
    data
  })
}

// 根据ID查询角色详细信息
export const getRoleIDApi = (id) => {
  return request({
    method: 'get',
    url: `roles/${id}`
  })
}

// 编辑提交角色
export const getEditRoleApi = (id, data) => {
  return request({
    method: 'put',
    url: `roles/${id}`,
    data
  })
}

// 删除角色
export const getDeleteRoleApi = (id) => {
  return request({
    method: 'delete',
    url: `roles/${id}`
  })
}

// 添加角色
export const getAddRoleApi = (data) => {
  return request({
    method: 'post',
    url: 'roles',
    data
  })
}
